<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- qtextobject.cpp -->
  <title>QTextBlock Class | Qt GUI 5.14.2</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.14</a></td><td ><a href="qtgui-index.html">Qt GUI</a></td><td ><a href="qtgui-module.html">C++ Classes</a></td><td >QTextBlock</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtgui-index.html">Qt 5.14.2 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QTextBlock Class</h1>
<!-- $$$QTextBlock-brief -->
<p>The QTextBlock class provides a container for text fragments in a <a href="qtextdocument.html">QTextDocument</a>. <a href="#details">More...</a></p>
<!-- @@@QTextBlock -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QTextBlock&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += gui</td></tr></table></div><ul>
<li><a href="qtextblock-members.html">List of all members, including inherited members</a></li>
</ul>
<p><b>Note:</b> All functions in this class are <a href="../qtdoc/threads-reentrancy.html">reentrant</a>.</p>
<a name="public-types"></a>
<h2 id="public-types">Public Types</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> class </td><td class="memItemRight bottomAlign"><b><a href="qtextblock-iterator.html">iterator</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#Iterator-typedef">Iterator</a></b></td></tr>
</table></div>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#QTextBlock-2">QTextBlock</a></b>(const QTextBlock &amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QTextBlock &amp;</td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#operator-eq">operator=</a></b>(const QTextBlock &amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QTextBlock::iterator </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#begin">begin</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QTextBlockFormat </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#blockFormat">blockFormat</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#blockFormatIndex">blockFormatIndex</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#blockNumber">blockNumber</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QTextCharFormat </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#charFormat">charFormat</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#charFormatIndex">charFormatIndex</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#clearLayout">clearLayout</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#contains">contains</a></b>(int <i>position</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QTextDocument *</td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#document">document</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QTextBlock::iterator </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#end">end</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#firstLineNumber">firstLineNumber</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#isValid">isValid</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#isVisible">isVisible</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QTextLayout *</td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#layout">layout</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#length">length</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#lineCount">lineCount</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QTextBlock </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#next">next</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#position">position</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QTextBlock </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#previous">previous</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#revision">revision</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#setLineCount">setLineCount</a></b>(int <i>count</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#setRevision">setRevision</a></b>(int <i>rev</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#setUserData">setUserData</a></b>(QTextBlockUserData *<i>data</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#setUserState">setUserState</a></b>(int <i>state</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#setVisible">setVisible</a></b>(bool <i>visible</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#text">text</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Qt::LayoutDirection </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#textDirection">textDirection</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVector&lt;QTextLayout::FormatRange&gt; </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#textFormats">textFormats</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QTextList *</td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#textList">textList</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QTextBlockUserData *</td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#userData">userData</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#userState">userState</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#operator-not-eq">operator!=</a></b>(const QTextBlock &amp;<i>other</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#operator-lt">operator&lt;</a></b>(const QTextBlock &amp;<i>other</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qtextblock.html#operator-eq-eq">operator==</a></b>(const QTextBlock &amp;<i>other</i>) const</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QTextBlock-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>A text block encapsulates a block or paragraph of text in a <a href="qtextdocument.html">QTextDocument</a>. QTextBlock provides read-only access to the block/paragraph structure of QTextDocuments. It is mainly of use if you want to implement your own layouts for the visual representation of a <a href="qtextdocument.html">QTextDocument</a>, or if you want to iterate over a document and write out the contents in your own custom format.</p>
<p>Text blocks are created by their parent documents. If you need to create a new text block, or modify the contents of a document while examining its contents, use the cursor-based interface provided by <a href="qtextcursor.html">QTextCursor</a> instead.</p>
<p>Each text block is located at a specific <a href="qtextblock.html#position">position</a>() in a <a href="qtextblock.html#document">document</a>(). The contents of the block can be obtained by using the <a href="qtextblock.html#text">text</a>() function. The <a href="qtextblock.html#length">length</a>() function determines the block's size within the document (including formatting characters). The visual properties of the block are determined by its text <a href="qtextblock.html#layout">layout</a>(), its <a href="qtextblock.html#charFormat">charFormat</a>(), and its <a href="qtextblock.html#blockFormat">blockFormat</a>().</p>
<p>The <a href="qtextblock.html#next">next</a>() and <a href="qtextblock.html#previous">previous</a>() functions enable iteration over consecutive valid blocks in a document under the condition that the document is not modified by other means during the iteration process. Note that, although blocks are returned in sequence, adjacent blocks may come from different places in the document structure. The validity of a block can be determined by calling <a href="qtextblock.html#isValid">isValid</a>().</p>
<p>QTextBlock provides comparison operators to make it easier to work with blocks: <a href="qtextblock.html#operator-eq-eq">operator==</a>() compares two block for equality, <a href="qtextblock.html#operator-not-eq">operator!=</a>() compares two blocks for inequality, and <a href="qtextblock.html#operator-lt">operator&lt;</a>() determines whether a block precedes another in the same document.</p>
<p class="centerAlign"><img src="images/qtextblock-sequence.png" alt="" /></p></div>
<p><b>See also </b><a href="qtextblockformat.html">QTextBlockFormat</a>, <a href="qtextcharformat.html">QTextCharFormat</a>, and <a href="qtextfragment.html">QTextFragment</a>.</p>
<!-- @@@QTextBlock -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$Iterator -->
<h3 class="fn" id="Iterator-typedef"><a name="Iterator-typedef"></a>typedef QTextBlock::<span class="name">Iterator</span></h3>
<p>Qt-style synonym for <a href="qtextblock-iterator.html">QTextBlock::iterator</a>.</p>
<!-- @@@Iterator -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QTextBlock$$$QTextBlockconstQTextBlock& -->
<h3 class="fn" id="QTextBlock-2"><a name="QTextBlock-2"></a>QTextBlock::<span class="name">QTextBlock</span>(const <span class="type">QTextBlock</span> &amp;<i>other</i>)</h3>
<p>Copies the <i>other</i> text block's attributes to this text block.</p>
<!-- @@@QTextBlock -->
<!-- $$$operator=[overload1]$$$operator=constQTextBlock& -->
<h3 class="fn" id="operator-eq"><a name="operator-eq"></a><span class="type">QTextBlock</span> &amp;QTextBlock::<span class="name">operator=</span>(const <span class="type">QTextBlock</span> &amp;<i>other</i>)</h3>
<p>Assigns the <i>other</i> text block to this text block.</p>
<!-- @@@operator= -->
<!-- $$$begin[overload1]$$$begin -->
<h3 class="fn" id="begin"><a name="begin"></a><span class="type"><a href="qtextblock-iterator.html">QTextBlock::iterator</a></span> QTextBlock::<span class="name">begin</span>() const</h3>
<p>Returns a text block iterator pointing to the beginning of the text block.</p>
<p><b>See also </b><a href="qtextblock.html#end">end</a>().</p>
<!-- @@@begin -->
<!-- $$$blockFormat[overload1]$$$blockFormat -->
<h3 class="fn" id="blockFormat"><a name="blockFormat"></a><span class="type"><a href="qtextblockformat.html">QTextBlockFormat</a></span> QTextBlock::<span class="name">blockFormat</span>() const</h3>
<p>Returns the <a href="qtextblockformat.html">QTextBlockFormat</a> that describes block-specific properties.</p>
<p><b>See also </b><a href="qtextblock.html#charFormat">charFormat</a>().</p>
<!-- @@@blockFormat -->
<!-- $$$blockFormatIndex[overload1]$$$blockFormatIndex -->
<h3 class="fn" id="blockFormatIndex"><a name="blockFormatIndex"></a><span class="type">int</span> QTextBlock::<span class="name">blockFormatIndex</span>() const</h3>
<p>Returns an index into the document's internal list of block formats for the text block's format.</p>
<p><b>See also </b><a href="qtextdocument.html#allFormats">QTextDocument::allFormats</a>().</p>
<!-- @@@blockFormatIndex -->
<!-- $$$blockNumber[overload1]$$$blockNumber -->
<h3 class="fn" id="blockNumber"><a name="blockNumber"></a><span class="type">int</span> QTextBlock::<span class="name">blockNumber</span>() const</h3>
<p>Returns the number of this block, or -1 if the block is invalid.</p>
<p>This function was introduced in Qt 4.4.</p>
<p><b>See also </b><a href="qtextcursor.html#blockNumber">QTextCursor::blockNumber</a>().</p>
<!-- @@@blockNumber -->
<!-- $$$charFormat[overload1]$$$charFormat -->
<h3 class="fn" id="charFormat"><a name="charFormat"></a><span class="type"><a href="qtextcharformat.html">QTextCharFormat</a></span> QTextBlock::<span class="name">charFormat</span>() const</h3>
<p>Returns the <a href="qtextcharformat.html">QTextCharFormat</a> that describes the block's character format. The block's character format is used when inserting text into an empty block.</p>
<p><b>See also </b><a href="qtextblock.html#blockFormat">blockFormat</a>().</p>
<!-- @@@charFormat -->
<!-- $$$charFormatIndex[overload1]$$$charFormatIndex -->
<h3 class="fn" id="charFormatIndex"><a name="charFormatIndex"></a><span class="type">int</span> QTextBlock::<span class="name">charFormatIndex</span>() const</h3>
<p>Returns an index into the document's internal list of character formats for the text block's character format.</p>
<p><b>See also </b><a href="qtextdocument.html#allFormats">QTextDocument::allFormats</a>().</p>
<!-- @@@charFormatIndex -->
<!-- $$$clearLayout[overload1]$$$clearLayout -->
<h3 class="fn" id="clearLayout"><a name="clearLayout"></a><span class="type">void</span> QTextBlock::<span class="name">clearLayout</span>()</h3>
<p>Clears the <a href="qtextlayout.html">QTextLayout</a> that is used to lay out and display the block's contents.</p>
<p>This function was introduced in Qt 4.4.</p>
<p><b>See also </b><a href="qtextblock.html#layout">layout</a>().</p>
<!-- @@@clearLayout -->
<!-- $$$contains[overload1]$$$containsint -->
<h3 class="fn" id="contains"><a name="contains"></a><span class="type">bool</span> QTextBlock::<span class="name">contains</span>(<span class="type">int</span> <i>position</i>) const</h3>
<p>Returns <code>true</code> if the given <i>position</i> is located within the text block; otherwise returns <code>false</code>.</p>
<!-- @@@contains -->
<!-- $$$document[overload1]$$$document -->
<h3 class="fn" id="document"><a name="document"></a>const <span class="type"><a href="qtextdocument.html">QTextDocument</a></span> *QTextBlock::<span class="name">document</span>() const</h3>
<p>Returns the text document this text block belongs to, or <code>nullptr</code> if the text block does not belong to any document.</p>
<!-- @@@document -->
<!-- $$$end[overload1]$$$end -->
<h3 class="fn" id="end"><a name="end"></a><span class="type"><a href="qtextblock-iterator.html">QTextBlock::iterator</a></span> QTextBlock::<span class="name">end</span>() const</h3>
<p>Returns a text block iterator pointing to the end of the text block.</p>
<p><b>See also </b><a href="qtextblock.html#begin">begin</a>(), <a href="qtextblock.html#next">next</a>(), and <a href="qtextblock.html#previous">previous</a>().</p>
<!-- @@@end -->
<!-- $$$firstLineNumber[overload1]$$$firstLineNumber -->
<h3 class="fn" id="firstLineNumber"><a name="firstLineNumber"></a><span class="type">int</span> QTextBlock::<span class="name">firstLineNumber</span>() const</h3>
<p>Returns the first line number of this block, or -1 if the block is invalid. Unless the layout supports it, the line number is identical to the block number.</p>
<p>This function was introduced in Qt 4.5.</p>
<p><b>See also </b><a href="qtextblock.html#blockNumber">QTextBlock::blockNumber</a>().</p>
<!-- @@@firstLineNumber -->
<!-- $$$isValid[overload1]$$$isValid -->
<h3 class="fn" id="isValid"><a name="isValid"></a><span class="type">bool</span> QTextBlock::<span class="name">isValid</span>() const</h3>
<p>Returns <code>true</code> if this text block is valid; otherwise returns <code>false</code>.</p>
<!-- @@@isValid -->
<!-- $$$isVisible[overload1]$$$isVisible -->
<h3 class="fn" id="isVisible"><a name="isVisible"></a><span class="type">bool</span> QTextBlock::<span class="name">isVisible</span>() const</h3>
<p>Returns <code>true</code> if the block is visible; otherwise returns <code>false</code>.</p>
<p>This function was introduced in Qt 4.4.</p>
<p><b>See also </b><a href="qtextblock.html#setVisible">setVisible</a>().</p>
<!-- @@@isVisible -->
<!-- $$$layout[overload1]$$$layout -->
<h3 class="fn" id="layout"><a name="layout"></a><span class="type"><a href="qtextlayout.html">QTextLayout</a></span> *QTextBlock::<span class="name">layout</span>() const</h3>
<p>Returns the <a href="qtextlayout.html">QTextLayout</a> that is used to lay out and display the block's contents.</p>
<p>Note that the returned <a href="qtextlayout.html">QTextLayout</a> object can only be modified from the documentChanged implementation of a <a href="qabstracttextdocumentlayout.html">QAbstractTextDocumentLayout</a> subclass. Any changes applied from the outside cause undefined behavior.</p>
<p><b>See also </b><a href="qtextblock.html#clearLayout">clearLayout</a>().</p>
<!-- @@@layout -->
<!-- $$$length[overload1]$$$length -->
<h3 class="fn" id="length"><a name="length"></a><span class="type">int</span> QTextBlock::<span class="name">length</span>() const</h3>
<p>Returns the length of the block in characters.</p>
<p><b>Note: </b>The length returned includes all formatting characters, for example, newline.</p><p><b>See also </b><a href="qtextblock.html#text">text</a>(), <a href="qtextblock.html#charFormat">charFormat</a>(), and <a href="qtextblock.html#blockFormat">blockFormat</a>().</p>
<!-- @@@length -->
<!-- $$$lineCount[overload1]$$$lineCount -->
<h3 class="fn" id="lineCount"><a name="lineCount"></a><span class="type">int</span> QTextBlock::<span class="name">lineCount</span>() const</h3>
<p>Returns the line count. Not all document layouts support this feature.</p>
<p>This function was introduced in Qt 4.5.</p>
<p><b>See also </b><a href="qtextblock.html#setLineCount">setLineCount</a>().</p>
<!-- @@@lineCount -->
<!-- $$$next[overload1]$$$next -->
<h3 class="fn" id="next"><a name="next"></a><span class="type">QTextBlock</span> QTextBlock::<span class="name">next</span>() const</h3>
<p>Returns the text block in the document after this block, or an empty text block if this is the last one.</p>
<p>Note that the next block may be in a different frame or table to this block.</p>
<p><b>See also </b><a href="qtextblock.html#previous">previous</a>(), <a href="qtextblock.html#begin">begin</a>(), and <a href="qtextblock.html#end">end</a>().</p>
<!-- @@@next -->
<!-- $$$position[overload1]$$$position -->
<h3 class="fn" id="position"><a name="position"></a><span class="type">int</span> QTextBlock::<span class="name">position</span>() const</h3>
<p>Returns the index of the block's first character within the document.</p>
<!-- @@@position -->
<!-- $$$previous[overload1]$$$previous -->
<h3 class="fn" id="previous"><a name="previous"></a><span class="type">QTextBlock</span> QTextBlock::<span class="name">previous</span>() const</h3>
<p>Returns the text block in the document before this block, or an empty text block if this is the first one.</p>
<p>Note that the previous block may be in a different frame or table to this block.</p>
<p><b>See also </b><a href="qtextblock.html#next">next</a>(), <a href="qtextblock.html#begin">begin</a>(), and <a href="qtextblock.html#end">end</a>().</p>
<!-- @@@previous -->
<!-- $$$revision[overload1]$$$revision -->
<h3 class="fn" id="revision"><a name="revision"></a><span class="type">int</span> QTextBlock::<span class="name">revision</span>() const</h3>
<p>Returns the blocks revision.</p>
<p>This function was introduced in Qt 4.4.</p>
<p><b>See also </b><a href="qtextblock.html#setRevision">setRevision</a>() and <a href="qtextdocument.html#revision">QTextDocument::revision</a>().</p>
<!-- @@@revision -->
<!-- $$$setLineCount[overload1]$$$setLineCountint -->
<h3 class="fn" id="setLineCount"><a name="setLineCount"></a><span class="type">void</span> QTextBlock::<span class="name">setLineCount</span>(<span class="type">int</span> <i>count</i>)</h3>
<p>Sets the line count to <i>count</i>.</p>
<p>This function was introduced in Qt 4.5.</p>
<p><b>See also </b><a href="qtextblock.html#lineCount">lineCount</a>().</p>
<!-- @@@setLineCount -->
<!-- $$$setRevision[overload1]$$$setRevisionint -->
<h3 class="fn" id="setRevision"><a name="setRevision"></a><span class="type">void</span> QTextBlock::<span class="name">setRevision</span>(<span class="type">int</span> <i>rev</i>)</h3>
<p>Sets a blocks revision to <i>rev</i>.</p>
<p>This function was introduced in Qt 4.4.</p>
<p><b>See also </b><a href="qtextblock.html#revision">revision</a>() and <a href="qtextdocument.html#revision">QTextDocument::revision</a>().</p>
<!-- @@@setRevision -->
<!-- $$$setUserData[overload1]$$$setUserDataQTextBlockUserData* -->
<h3 class="fn" id="setUserData"><a name="setUserData"></a><span class="type">void</span> QTextBlock::<span class="name">setUserData</span>(<span class="type"><a href="qtextblockuserdata.html">QTextBlockUserData</a></span> *<i>data</i>)</h3>
<p>Attaches the given <i>data</i> object to the text block.</p>
<p><a href="qtextblockuserdata.html">QTextBlockUserData</a> can be used to store custom settings. The ownership is passed to the underlying text document, i.e&#x2e; the provided <a href="qtextblockuserdata.html">QTextBlockUserData</a> object will be deleted if the corresponding text block gets deleted. The user data object is not stored in the undo history, so it will not be available after undoing the deletion of a text block.</p>
<p>For example, if you write a programming editor in an IDE, you may want to let your user set breakpoints visually in your code for an integrated debugger. In a programming editor a line of text usually corresponds to one <a href="qtextblock.html">QTextBlock</a>. The <a href="qtextblockuserdata.html">QTextBlockUserData</a> interface allows the developer to store data for each <a href="qtextblock.html">QTextBlock</a>, like for example in which lines of the source code the user has a breakpoint set. Of course this could also be stored externally, but by storing it inside the <a href="qtextdocument.html">QTextDocument</a>, it will for example be automatically deleted when the user deletes the associated line. It's really just a way to store custom information in the <a href="qtextdocument.html">QTextDocument</a> without using custom properties in <a href="qtextformat.html">QTextFormat</a> which would affect the undo/redo stack.</p>
<p>This function was introduced in Qt 4.1.</p>
<p><b>See also </b><a href="qtextblock.html#userData">userData</a>().</p>
<!-- @@@setUserData -->
<!-- $$$setUserState[overload1]$$$setUserStateint -->
<h3 class="fn" id="setUserState"><a name="setUserState"></a><span class="type">void</span> QTextBlock::<span class="name">setUserState</span>(<span class="type">int</span> <i>state</i>)</h3>
<p>Stores the specified <i>state</i> integer value in the text block. This may be useful for example in a syntax highlighter to store a text parsing state.</p>
<p>This function was introduced in Qt 4.1.</p>
<p><b>See also </b><a href="qtextblock.html#userState">userState</a>().</p>
<!-- @@@setUserState -->
<!-- $$$setVisible[overload1]$$$setVisiblebool -->
<h3 class="fn" id="setVisible"><a name="setVisible"></a><span class="type">void</span> QTextBlock::<span class="name">setVisible</span>(<span class="type">bool</span> <i>visible</i>)</h3>
<p>Sets the block's visibility to <i>visible</i>.</p>
<p>This function was introduced in Qt 4.4.</p>
<p><b>See also </b><a href="qtextblock.html#isVisible">isVisible</a>().</p>
<!-- @@@setVisible -->
<!-- $$$text[overload1]$$$text -->
<h3 class="fn" id="text"><a name="text"></a><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QTextBlock::<span class="name">text</span>() const</h3>
<p>Returns the block's contents as plain text.</p>
<p><b>See also </b><a href="qtextblock.html#length">length</a>(), <a href="qtextblock.html#charFormat">charFormat</a>(), and <a href="qtextblock.html#blockFormat">blockFormat</a>().</p>
<!-- @@@text -->
<!-- $$$textDirection[overload1]$$$textDirection -->
<h3 class="fn" id="textDirection"><a name="textDirection"></a><span class="type"><a href="../qtcore/qt.html#LayoutDirection-enum">Qt::LayoutDirection</a></span> QTextBlock::<span class="name">textDirection</span>() const</h3>
<p>Returns the resolved text direction.</p>
<p>If the block has no explicit direction set, it will resolve the direction from the blocks content. Returns either <a href="../qtcore/qt.html#LayoutDirection-enum">Qt::LeftToRight</a> or <a href="../qtcore/qt.html#LayoutDirection-enum">Qt::RightToLeft</a>.</p>
<p>This function was introduced in Qt 4.7.</p>
<p><b>See also </b><a href="qtextformat.html#layoutDirection">QTextFormat::layoutDirection</a>(), <a href="../qtcore/qstring.html#isRightToLeft">QString::isRightToLeft</a>(), and <a href="../qtcore/qt.html#LayoutDirection-enum">Qt::LayoutDirection</a>.</p>
<!-- @@@textDirection -->
<!-- $$$textFormats[overload1]$$$textFormats -->
<h3 class="fn" id="textFormats"><a name="textFormats"></a><span class="type"><a href="../qtcore/qvector.html">QVector</a></span>&lt;<span class="type"><a href="qtextlayout-formatrange.html">QTextLayout::FormatRange</a></span>&gt; QTextBlock::<span class="name">textFormats</span>() const</h3>
<p>Returns the block's text format options as a list of continuous ranges of <a href="qtextcharformat.html">QTextCharFormat</a>. The range's character format is used when inserting text within the range boundaries.</p>
<p>This function was introduced in Qt 5.3.</p>
<p><b>See also </b><a href="qtextblock.html#charFormat">charFormat</a>() and <a href="qtextblock.html#blockFormat">blockFormat</a>().</p>
<!-- @@@textFormats -->
<!-- $$$textList[overload1]$$$textList -->
<h3 class="fn" id="textList"><a name="textList"></a><span class="type"><a href="qtextlist.html">QTextList</a></span> *QTextBlock::<span class="name">textList</span>() const</h3>
<p>If the block represents a list item, returns the list that the item belongs to; otherwise returns <code>nullptr</code>.</p>
<!-- @@@textList -->
<!-- $$$userData[overload1]$$$userData -->
<h3 class="fn" id="userData"><a name="userData"></a><span class="type"><a href="qtextblockuserdata.html">QTextBlockUserData</a></span> *QTextBlock::<span class="name">userData</span>() const</h3>
<p>Returns a pointer to a <a href="qtextblockuserdata.html">QTextBlockUserData</a> object, if one has been set with <a href="qtextblock.html#setUserData">setUserData</a>(), or <code>nullptr</code>.</p>
<p>This function was introduced in Qt 4.1.</p>
<p><b>See also </b><a href="qtextblock.html#setUserData">setUserData</a>().</p>
<!-- @@@userData -->
<!-- $$$userState[overload1]$$$userState -->
<h3 class="fn" id="userState"><a name="userState"></a><span class="type">int</span> QTextBlock::<span class="name">userState</span>() const</h3>
<p>Returns the integer value previously set with <a href="qtextblock.html#setUserState">setUserState</a>() or -1.</p>
<p>This function was introduced in Qt 4.1.</p>
<p><b>See also </b><a href="qtextblock.html#setUserState">setUserState</a>().</p>
<!-- @@@userState -->
<!-- $$$operator!=[overload1]$$$operator!=constQTextBlock& -->
<h3 class="fn" id="operator-not-eq"><a name="operator-not-eq"></a><span class="type">bool</span> QTextBlock::<span class="name">operator!=</span>(const <span class="type">QTextBlock</span> &amp;<i>other</i>) const</h3>
<p>Returns <code>true</code> if this text block is different from the <i>other</i> text block.</p>
<!-- @@@operator!= -->
<!-- $$$operator<[overload1]$$$operator<constQTextBlock& -->
<h3 class="fn" id="operator-lt"><a name="operator-lt"></a><span class="type">bool</span> QTextBlock::<span class="name">operator&lt;</span>(const <span class="type">QTextBlock</span> &amp;<i>other</i>) const</h3>
<p>Returns <code>true</code> if this text block occurs before the <i>other</i> text block in the document.</p>
<!-- @@@operator< -->
<!-- $$$operator==[overload1]$$$operator==constQTextBlock& -->
<h3 class="fn" id="operator-eq-eq"><a name="operator-eq-eq"></a><span class="type">bool</span> QTextBlock::<span class="name">operator==</span>(const <span class="type">QTextBlock</span> &amp;<i>other</i>) const</h3>
<p>Returns <code>true</code> if this text block is the same as the <i>other</i> text block.</p>
<!-- @@@operator== -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2020 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
